package com.fitns.user.mapper.baseConfig;

import static com.fitns.user.mapper.baseConfig.TbCollectDataDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.fitns.user.model.baseConfig.TbCollectData;

import java.util.List;
import javax.annotation.Generated;

import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;

@Mapper
public interface TbCollectDataMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="record.id", before=false, resultType=Long.class)
    int insert(InsertStatementProvider<TbCollectData> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TbCollectDataResult")
    TbCollectData selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TbCollectDataResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="organ_id", property="organId", jdbcType=JdbcType.BIGINT),
        @Result(column="village_name", property="villageName", jdbcType=JdbcType.VARCHAR),
        @Result(column="belong_road", property="belongRoad", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.TINYINT),
        @Result(column="acreage", property="acreage", jdbcType=JdbcType.VARCHAR),
        @Result(column="counter", property="counter", jdbcType=JdbcType.VARCHAR),
        @Result(column="population", property="population", jdbcType=JdbcType.INTEGER),
        @Result(column="liabler", property="liabler", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="terminal", property="terminal", jdbcType=JdbcType.VARCHAR),
        @Result(column="rfid", property="rfid", jdbcType=JdbcType.VARCHAR),
        @Result(column= "image", property= "image", jdbcType=JdbcType.VARCHAR),
        @Result(column="descs", property="descs", jdbcType=JdbcType.VARCHAR),
        @Result(column="begin_time", property="beginTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="input_time", property="inputTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="create_id", property="createId", jdbcType=JdbcType.BIGINT),
        @Result(column="modify_d", property="modifyD", jdbcType=JdbcType.BIGINT)
    })
    List<TbCollectData> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(tbCollectData);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, tbCollectData);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(Long id_) {
        return DeleteDSL.deleteFromWithMapper(this::delete, tbCollectData)
                .where(id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(TbCollectData record) {
        return insert(SqlBuilder.insert(record)
                .into(tbCollectData)
                .map(name).toProperty("name")
                .map(organId).toProperty("organId")
                .map(villageName).toProperty("villageName")
                .map(belongRoad).toProperty("belongRoad")
                .map(status).toProperty("status")
                .map(acreage).toProperty("acreage")
                .map(counter).toProperty("counter")
                .map(population).toProperty("population")
                .map(liabler).toProperty("liabler")
                .map(phone).toProperty("phone")
                .map(terminal).toProperty("terminal")
                .map(rfid).toProperty("rfid")
                .map(image).toProperty("image")
                .map(descs).toProperty("descs")
                .map(beginTime).toProperty("beginTime")
                .map(inputTime).toProperty("inputTime")
                .map(modifyTime).toProperty("modifyTime")
                .map(createId).toProperty("createId")
                .map(modifyD).toProperty("modifyD")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(TbCollectData record) {
        return insert(SqlBuilder.insert(record)
                .into(tbCollectData)
                .map(name).toPropertyWhenPresent("name", record::getName)
                .map(organId).toPropertyWhenPresent("organId", record::getOrganId)
                .map(villageName).toPropertyWhenPresent("villageName", record::getVillageName)
                .map(belongRoad).toPropertyWhenPresent("belongRoad", record::getBelongRoad)
                .map(status).toPropertyWhenPresent("status", record::getStatus)
                .map(acreage).toPropertyWhenPresent("acreage", record::getAcreage)
                .map(counter).toPropertyWhenPresent("counter", record::getCounter)
                .map(population).toPropertyWhenPresent("population", record::getPopulation)
                .map(liabler).toPropertyWhenPresent("liabler", record::getLiabler)
                .map(phone).toPropertyWhenPresent("phone", record::getPhone)
                .map(terminal).toPropertyWhenPresent("terminal", record::getTerminal)
                .map(rfid).toPropertyWhenPresent("rfid", record::getRfid)
                .map(image).toPropertyWhenPresent("image", record::getImage)
                .map(descs).toPropertyWhenPresent("descs", record::getDescs)
                .map(beginTime).toPropertyWhenPresent("beginTime", record::getBeginTime)
                .map(inputTime).toPropertyWhenPresent("inputTime", record::getInputTime)
                .map(modifyTime).toPropertyWhenPresent("modifyTime", record::getModifyTime)
                .map(createId).toPropertyWhenPresent("createId", record::getCreateId)
                .map(modifyD).toPropertyWhenPresent("modifyD", record::getModifyD)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbCollectData>>> selectByExample() {
        return SelectDSL.selectWithMapper(this::selectMany, id, name, organId, villageName, belongRoad, status, acreage, counter, population, liabler, phone, terminal, rfid, image, descs, beginTime, inputTime, modifyTime, createId, modifyD)
                .from(tbCollectData);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbCollectData>>> selectDistinctByExample() {
        return SelectDSL.selectDistinctWithMapper(this::selectMany, id, name, organId, villageName, belongRoad, status, acreage, counter, population, liabler, phone, terminal, rfid, image, descs, beginTime, inputTime, modifyTime, createId, modifyD)
                .from(tbCollectData);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default TbCollectData selectByPrimaryKey(Long id_) {
        return SelectDSL.selectWithMapper(this::selectOne, id, name, organId, villageName, belongRoad, status, acreage, counter, population, liabler, phone, terminal, rfid, image, descs, beginTime, inputTime, modifyTime, createId, modifyD)
                .from(tbCollectData)
                .where(id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(TbCollectData record) {
        return UpdateDSL.updateWithMapper(this::update, tbCollectData)
                .set(name).equalTo(record::getName)
                .set(organId).equalTo(record::getOrganId)
                .set(villageName).equalTo(record::getVillageName)
                .set(belongRoad).equalTo(record::getBelongRoad)
                .set(status).equalTo(record::getStatus)
                .set(acreage).equalTo(record::getAcreage)
                .set(counter).equalTo(record::getCounter)
                .set(population).equalTo(record::getPopulation)
                .set(liabler).equalTo(record::getLiabler)
                .set(phone).equalTo(record::getPhone)
                .set(terminal).equalTo(record::getTerminal)
                .set(rfid).equalTo(record::getRfid)
                .set(image).equalTo(record::getImage)
                .set(descs).equalTo(record::getDescs)
                .set(beginTime).equalTo(record::getBeginTime)
                .set(inputTime).equalTo(record::getInputTime)
                .set(modifyTime).equalTo(record::getModifyTime)
                .set(createId).equalTo(record::getCreateId)
                .set(modifyD).equalTo(record::getModifyD);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(TbCollectData record) {
        return UpdateDSL.updateWithMapper(this::update, tbCollectData)
                .set(name).equalToWhenPresent(record::getName)
                .set(organId).equalToWhenPresent(record::getOrganId)
                .set(villageName).equalToWhenPresent(record::getVillageName)
                .set(belongRoad).equalToWhenPresent(record::getBelongRoad)
                .set(status).equalToWhenPresent(record::getStatus)
                .set(acreage).equalToWhenPresent(record::getAcreage)
                .set(counter).equalToWhenPresent(record::getCounter)
                .set(population).equalToWhenPresent(record::getPopulation)
                .set(liabler).equalToWhenPresent(record::getLiabler)
                .set(phone).equalToWhenPresent(record::getPhone)
                .set(terminal).equalToWhenPresent(record::getTerminal)
                .set(rfid).equalToWhenPresent(record::getRfid)
                .set(image).equalToWhenPresent(record::getImage)
                .set(descs).equalToWhenPresent(record::getDescs)
                .set(beginTime).equalToWhenPresent(record::getBeginTime)
                .set(inputTime).equalToWhenPresent(record::getInputTime)
                .set(modifyTime).equalToWhenPresent(record::getModifyTime)
                .set(createId).equalToWhenPresent(record::getCreateId)
                .set(modifyD).equalToWhenPresent(record::getModifyD);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(TbCollectData record) {
        return UpdateDSL.updateWithMapper(this::update, tbCollectData)
                .set(name).equalTo(record::getName)
                .set(organId).equalTo(record::getOrganId)
                .set(villageName).equalTo(record::getVillageName)
                .set(belongRoad).equalTo(record::getBelongRoad)
                .set(status).equalTo(record::getStatus)
                .set(acreage).equalTo(record::getAcreage)
                .set(counter).equalTo(record::getCounter)
                .set(population).equalTo(record::getPopulation)
                .set(liabler).equalTo(record::getLiabler)
                .set(phone).equalTo(record::getPhone)
                .set(terminal).equalTo(record::getTerminal)
                .set(rfid).equalTo(record::getRfid)
                .set(image).equalTo(record::getImage)
                .set(descs).equalTo(record::getDescs)
                .set(beginTime).equalTo(record::getBeginTime)
                .set(inputTime).equalTo(record::getInputTime)
                .set(modifyTime).equalTo(record::getModifyTime)
                .set(createId).equalTo(record::getCreateId)
                .set(modifyD).equalTo(record::getModifyD)
                .where(id, isEqualTo(record::getId))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(TbCollectData record) {
        return UpdateDSL.updateWithMapper(this::update, tbCollectData)
                .set(name).equalToWhenPresent(record::getName)
                .set(organId).equalToWhenPresent(record::getOrganId)
                .set(villageName).equalToWhenPresent(record::getVillageName)
                .set(belongRoad).equalToWhenPresent(record::getBelongRoad)
                .set(status).equalToWhenPresent(record::getStatus)
                .set(acreage).equalToWhenPresent(record::getAcreage)
                .set(counter).equalToWhenPresent(record::getCounter)
                .set(population).equalToWhenPresent(record::getPopulation)
                .set(liabler).equalToWhenPresent(record::getLiabler)
                .set(phone).equalToWhenPresent(record::getPhone)
                .set(terminal).equalToWhenPresent(record::getTerminal)
                .set(rfid).equalToWhenPresent(record::getRfid)
                .set(image).equalToWhenPresent(record::getImage)
                .set(descs).equalToWhenPresent(record::getDescs)
                .set(beginTime).equalToWhenPresent(record::getBeginTime)
                .set(inputTime).equalToWhenPresent(record::getInputTime)
                .set(modifyTime).equalToWhenPresent(record::getModifyTime)
                .set(createId).equalToWhenPresent(record::getCreateId)
                .set(modifyD).equalToWhenPresent(record::getModifyD)
                .where(id, isEqualTo(record::getId))
                .build()
                .execute();
    }
}